/**
 * 2010-2011 xiha.org
 */
package org.xiha.wiki.apps;

import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;
import org.xiha.web.DoInvoke;
import org.xiha.web.Param;
import org.xiha.wiki.database.AckView;
import org.xiha.wiki.database.BasicDatabase;
import org.xiha.wiki.domain.Ack;

/**
 * @author summer
 * 
 */
public class Edit {
    
    @DoInvoke(tt = "edit.vm")
    public Ack showEdit(@Param(name = "subject") String subject, @Param(name = "key") String key) {
        Ack ack = null;
        if ("summer".equals(key)) {
            BasicDatabase db = new BasicDatabase("~/");
            
            db.openAck();
            AckView basicView = new AckView(db);
            
            Map<String, Ack> acks = basicView.getAckStoredMap();
            
            ack = acks.get(DigestUtils.md5Hex(subject));
            
            db.closeAck();
        }
        
        return ack;
    }
}
